package sg.edu.nus.iss.vmcs.util;
/*
 * Copyright 2011 ISS.
 * The contents contained in this document may not be reproduced in any
 * form or by any means, without the written permission of ISS, other
 * than for the purpose for which it has been supplied.
 *
 */

import java.awt.event.*;
import java.awt.*;

/**
 * This class represents the message dialog that initiates on the display
 * of any message. It inherits from the Java AWT Dialog Class. It implements
 * the interface ActionListener from Java AWT Event package
 *
 * @version 1.0  09/12/2011
 * @author Team 7S - SE19
 */

public class MessageDialog extends Dialog implements ActionListener {

/**
 * This constructor creates a new instance of the MessageDialog. 
 * @param fr Dialog
 * @param msg Message to be displayed
 */	
	public MessageDialog(Dialog fr, String msg) {
		super(fr, "Message", true);

		this.setLayout(new BorderLayout());

		Label lb = new Label(msg);

		Button ok = new Button("OK");

		this.add("Center", lb);
		this.add("South", ok);

		ok.addActionListener(this);
		pack();
		setLocation(200, 100);
		this.setVisible(true);
	}

/**
 * Invoked when an action occurs in response to the button being pressed. 
 * Implemented as a part of interface.
 * @param e ActionEvent  
 */	
	public void actionPerformed(ActionEvent e) {
		this.dispose();
	}

}